/******************************************************************************
 * Copyright (C) 2017 Chengdu Dlhd information industry co. LTD.
 * All Rights Reserved.
 * 本软件为成都顶联互动信息产业有限公司开发研制。未经本公司正式书面同意，其他任何个人、团体不得使用、复制、修改或发布本软件.
 *****************************************************************************/
package net.dgg.dggcloud.service.jrcrm.service.cms;


import net.dgg.dggcloud.service.common.base.service.BaseService;
import net.dgg.dggcloud.service.jrcrm.dao.cms.SmsTemplateDao;
import net.dgg.dggcloud.service.jrcrm.entity.cms.SmsTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @ClassName 〈SmsTemplateService>
 * @Description 短信模版service层
 * @Author 朱永波
 * @Date 2017/11/1 17:58
 */
@Service
public class SmsTemplateService extends BaseService {

    @Autowired
    private SmsTemplateDao smsTemplateDao;

    public Integer countSmsTemplateByMap(Map map) {
        return smsTemplateDao.countSmsTemplateByMap(map);
    }

    public List<Map> listSmsTemplateByMap(Map map) {
        return smsTemplateDao.listSmsTemplateByMap(map);
    }

    public void deleteSmsTemplateByIdHiber(String[] arryIds) {

        for (int i = 0; i < arryIds.length; i++)
        {
            this.repository.deleteEntityById(SmsTemplate.class, Long.parseLong(arryIds[i]));
        }
    }

    public SmsTemplate getById(Long id) {
        return repository.get(SmsTemplate.class,id);
    }

    public void updateSmsTemplate(SmsTemplate oldTemplate) {
        repository.saveOrUpdate(oldTemplate);
    }

    public void saveSmsTemplate(SmsTemplate template) {
        repository.save(template);
    }
}
